package top.zhangjianyong.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zhangjianyong.tools.entity.stock.StockUser;
import top.zhangjianyong.tools.parm.stock.*;
import top.zhangjianyong.tools.service.api.StockGoodsService;
import top.zhangjianyong.tools.user.VerifyUser;
import top.zhangjianyong.tools.utils.ApiResponse;

/**
 * @author zhangjianyong
 * @since 2025/3/25 下午3:43
 */
@VerifyUser(user = StockUser.class, admin = true)
@RestController
@RequestMapping("/stock/goods")
public class StockGoodsController {

    @Autowired
    private StockGoodsService stockGoodsService;

    @PostMapping("/save")
    public ApiResponse save(@RequestBody @Validated StockGoodsSaveParam param) {
        return stockGoodsService.save(param);
    }

    @PostMapping("/update")
    public ApiResponse update(@RequestBody @Validated StockGoodsUpdateParam param) {
        return stockGoodsService.update(param);
    }

    @PostMapping("/del")
    public ApiResponse del(@RequestBody StockGoodsDelParam param) {
        return stockGoodsService.del(param);
    }

    @PostMapping("/list")
    public ApiResponse list(@RequestBody StockGoodsListParam param) {
        return stockGoodsService.list(param);
    }

    @PostMapping("/user/list")
    public ApiResponse userList(@RequestBody @Validated StockUserGoodsUserListParam param) {
        return stockGoodsService.userList(param);
    }

}
